import { Label, log, Node, UITransform, _decorator } from 'cc';
import VirtualItem from '../../../../../app-core/common/component/virtuallist/VirtualItem';
import { VirtualArgs } from '../../../../../app-core/common/component/virtuallist/VirtualList';
const { ccclass, property } = _decorator;

export interface ItemArgs extends VirtualArgs {
    num: number;
}


@ccclass('ListItemComp')
export class ListItemComp extends VirtualItem<ItemArgs> {
    @property(Node) bg: Node = null;
    @property(Label) lab: Label = null;

    /**
    * @override
    */
    public onRefresh(args: ItemArgs) {
        this.lab.string = `idx: ${this.dataIdx}`;
        this.node.getComponent(UITransform).height = args.num;
        this.bg.getComponent(UITransform).height = this.node.getComponent(UITransform).height - 20;

        log(`[ListItemComp.onRefresh] idx: ${this.dataIdx}, args.num: ${args.num}`);
    }

    /**
     * @override
     */
    public onRefreshOthers(labNode: Node) {
    }
}


